package com.jvmmonitor.model;

/**
 * 对象大小统计数据模型
 */
public class ObjectSizeStats {
    // 小对象统计 (< 1KB)
    private long smallObjectCount;
    private long smallObjectTotalSize;
    
    // 中等对象统计 (1KB - 1MB)
    private long mediumObjectCount;
    private long mediumObjectTotalSize;
    
    // 大对象统计 (> 1MB)
    private long largeObjectCount;
    private long largeObjectTotalSize;
    
    // 总对象统计
    private long totalObjectCount;
    private long totalObjectSize;
    
    // 时间戳
    private long timestamp;
    
    // Getters and Setters
    public long getSmallObjectCount() {
        return smallObjectCount;
    }
    
    public void setSmallObjectCount(long smallObjectCount) {
        this.smallObjectCount = smallObjectCount;
    }
    
    public long getSmallObjectTotalSize() {
        return smallObjectTotalSize;
    }
    
    public void setSmallObjectTotalSize(long smallObjectTotalSize) {
        this.smallObjectTotalSize = smallObjectTotalSize;
    }
    
    public long getMediumObjectCount() {
        return mediumObjectCount;
    }
    
    public void setMediumObjectCount(long mediumObjectCount) {
        this.mediumObjectCount = mediumObjectCount;
    }
    
    public long getMediumObjectTotalSize() {
        return mediumObjectTotalSize;
    }
    
    public void setMediumObjectTotalSize(long mediumObjectTotalSize) {
        this.mediumObjectTotalSize = mediumObjectTotalSize;
    }
    
    public long getLargeObjectCount() {
        return largeObjectCount;
    }
    
    public void setLargeObjectCount(long largeObjectCount) {
        this.largeObjectCount = largeObjectCount;
    }
    
    public long getLargeObjectTotalSize() {
        return largeObjectTotalSize;
    }
    
    public void setLargeObjectTotalSize(long largeObjectTotalSize) {
        this.largeObjectTotalSize = largeObjectTotalSize;
    }
    
    public long getTotalObjectCount() {
        return totalObjectCount;
    }
    
    public void setTotalObjectCount(long totalObjectCount) {
        this.totalObjectCount = totalObjectCount;
    }
    
    public long getTotalObjectSize() {
        return totalObjectSize;
    }
    
    public void setTotalObjectSize(long totalObjectSize) {
        this.totalObjectSize = totalObjectSize;
    }
    
    public long getTimestamp() {
        return timestamp;
    }
    
    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }
    
    // 计算各类型对象占比
    public double getSmallObjectRatio() {
        return totalObjectSize == 0 ? 0 : (double) smallObjectTotalSize / totalObjectSize;
    }
    
    public double getMediumObjectRatio() {
        return totalObjectSize == 0 ? 0 : (double) mediumObjectTotalSize / totalObjectSize;
    }
    
    public double getLargeObjectRatio() {
        return totalObjectSize == 0 ? 0 : (double) largeObjectTotalSize / totalObjectSize;
    }
    
    @Override
    public String toString() {
        return "ObjectSizeStats{" +
                "smallObjectCount=" + smallObjectCount +
                ", smallObjectTotalSize=" + smallObjectTotalSize +
                ", mediumObjectCount=" + mediumObjectCount +
                ", mediumObjectTotalSize=" + mediumObjectTotalSize +
                ", largeObjectCount=" + largeObjectCount +
                ", largeObjectTotalSize=" + largeObjectTotalSize +
                ", totalObjectCount=" + totalObjectCount +
                ", totalObjectSize=" + totalObjectSize +
                ", timestamp=" + timestamp +
                '}';
    }
}